package cn.wangbencun.qrcode.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import cn.wangbencun.qrcode.R;

public class SplashActivity extends Activity {
    private ImageView imageView_title;
    private ImageView imageView_body;
    private Context context;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        context =this;
        initView();
        initAniamtion();
        goThread();

    }

    private void goThread() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(3000);
                    Intent intent = new Intent();
                    intent.setClass(context,MainActivity.class);
                    startActivity(intent);
                    finish();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }

    private void initAniamtion() {
        imageView_title.setAnimation(AnimationUtils.loadAnimation(context, R.anim.spliish_stitle));
        imageView_body.setAnimation(AnimationUtils.loadAnimation(context,R.anim.splish_body));
    }

    private void initView() {
        imageView_body = (ImageView) findViewById(R.id.imageView_body);
        imageView_title = (ImageView) findViewById(R.id.imageView_title);
    }

}
